﻿using System;

namespace AIC_Notification
{
    static public class CityDB
    {
        public enum CityEnum { Beijing, Chengdu, Hangzhou, Shanghai, Shenzhen, Xian, NewJersey };

        static public City[] Cities;
        static public int NoOfCities;
        static private string[] CityName = { "Beijing", "Chengdu", "Hangzhou", "Shanghai", "Shenzhen", "Xian", "New Jersey" };
        static private string[] CityServiceGroupEmail = { "bjservice@jq-edu.com", "aic-chengdu@jq-edu.com", "hzservice@jq-edu.com", "shservice@jq-edu.com", "aic-shenzhen@jq-edu.com", "aic-xian@jq-edu.com", "bjservice@jq-edu.com" };

        static public bool Initialize()
        {
            NoOfCities = Enum.GetNames(typeof(CityEnum)).Length;

            Cities = new City[NoOfCities];
            {
                for (int i = 0; i < NoOfCities; i++)
                    Cities[i] = new City(i);
            }

            return true;
        }

        static public string GetCityName(CityEnum City)
        {
            return CityName[(int)City];
        }

        static public City GetCityByName(string Name)
        {
            City TargetCity = null;

            switch (Name)
            {
                case "Beijing":
                case "北京":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.Beijing];
                    break;
                case "Chengdu":
                case "成都":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.Chengdu];
                    break;
                case "Hangzhou":
                case "杭州":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.Hangzhou];
                    break;
                case "Shanghai":
                case "上海":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.Shanghai];
                    break;
                case "Shenzhen":
                case "深圳":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.Shenzhen];
                    break;
                case "Xi'an":
                case "Xian":
                case "西安":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.Xian];
                    break;
                case "New Jersey":
                    TargetCity = CityDB.Cities[(int)CityDB.CityEnum.NewJersey];
                    break;
                default:
                    break;
            }

            return TargetCity;
        }

        static public string GetCityServiceGroupEmail(CityEnum ServiceCity)
        {
            return CityServiceGroupEmail[(int)ServiceCity];
        }
    }
}
